home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-18 | 3.0 KB | 95 lines | [TEXT/ttxt] |
- \ Revised Time manager...used for any system >6.0.3 - assumes register A1
- \ contains address of record at proc call
- \ 5/18/93 rfl revised for new gestalt of version 3.64
-
- \ Read IMIV for a description of what this might be used for..care must
- \ be taken not to move memory, rely on unlocked handles, etc.
- \ Remember to remove tasks prior to exiting the application.
-
- create Tinstall ( ptr -- result) popA0 " InsTime" asmcall pushd0 next,
- create Tremove ( ptr -- result) popA0 " rmvTime" asmcall pushd0 next,
- create Tprime ( len ptr -- result) popD0 popA0 " primeTime" asmcall pushd0 next,
-
-
- :CLASS timeTask <super object
-
- int microseconds \ true if delay in microseconds
- var myProc \ myProc in relative address, will move on install
- var tmDelay
-
- var qlink \ setup extended record, even though this is revised class
- int qtype
- var tmAddr
- var tmCount
-
- :M init: ( 'cfaProc --) >body put: myProc ;M
-
- :M microseconds: ( b --) put: microseconds ;M
-
- \ once installed, and then removed, you may reInstall using this method
- :M reInstall: ( --) get: myProc +base put: tmAddr
- clear: qType clear: qLink clear: tmCount
- abs: qlink Tinstall abort" can't install" ;M
-
- \ Use this method as the first thing...It loads up the record with values
- :M install: ( -- ) get: myProc body> initProc reInstall: self ;M
-
- \ To remove the task from the queue
- :M remove: ( --) abs: qlink Tremove abort" can't remove" ;M
-
- \ positive value is milliseconds, negative value is microseconds
- :M setDelay: ( n --) get: microseconds IF negate THEN put: tmDelay ;M
-
- :M getDelay: ( -- n) get: tmDelay get: microseconds IF negate THEN ;M
-
- \ start the task...it doesn't repeat, but must be restarted for continuous operation
- :M go: abs: qlink get: tmDelay Tprime abort" can't start" ;M
-
- :M start: go: self ;M
-
- :M stop: remove: self ;M
-
- \ return time remaining during countdown
- :M time: ( -- microseconds) get: tmCount 20 * ;M
-
- \ return time remaining after task has been stopped or executed
- :M remaining: ( -- microseconds) get: tmCount negate ;M
-
- \ return time elapsed after task has been stopped or executed
- :M elapsed: ( -- microsecs) get: tmCount get: tmDelay
- get: microseconds
- IF - ELSE -1000 * - THEN ;M
-
- :M on: ( --b) 'type sysv (gestalt) 0= \ check if revised TM
- IF $ 603 >=
- IF get: qType $ 8000 and
- IF true ELSE false THEN
- ELSE ." not supported
- THEN
- ELSE ." not supported"
- THEN ;M
-
- :M pause: stop: self ;M
- \ continue counting after a pause...will count so that timer will run for original delay
- :M resume: remaining: self get: microseconds not
- IF 1000 / THEN setDelay: self reinstall: self go: self ;M
-
- ;CLASS
-
- \ procedure is to install a TprocWord, set the delay when the TprocWord should execute,
- \ and when you want to start timing, say go:
- \ When you're completely done, just remove:
-
- \ rect suz
- \ 100 100 200 200 put: suz
- \
- \ timeTask painter
- \ :proc paintit pushPort set: fwind paint: suz popPort ;proc
- \ 5000 setdelay: painter
- \
- \ 'c paintit init: painter
- \ install: painter
- \ go: painter
-
-
-